﻿@using Smart.Project.Data
@model MEvent
@{
    Layout = null;
}
<link href="~/Content/css/styles.css" rel="stylesheet" />
<link href="~/Content/css/styles-blue.css" rel="stylesheet" />
<link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/css/new-styles.css" rel="stylesheet" />
<link href="~/Content/select/css/select2.min.css" rel="stylesheet" />
<link href="~/Content/js/layui/css/layui.css" rel="stylesheet" />
<link href="~/Content/js/vendors/jsPanel/jquery.jspanel.css" rel="stylesheet" />

<script src="~/Content/js/vendors/jquery/jquery.min.js"></script>
<script src="~/Content/js/vendors/jquery/jquery-ui.min.js"></script>
<script src="~/Content/js/vendors/bootstrap/bootstrap.min.js"></script>
<script src="~/Content/js/vendors/form/jquery.form.min.js"></script>
<script src="~/Content/js/vendors/form/jquery.validate.min.js"></script>
<script src="~/Content/js/vendors/slimScroll/jquery.slimscroll.min.js"></script>
<script src="~/Content/js/index.js"></script>
<script src="~/Content/select/js/select2.js"></script>
<script src="~/Content/js/layui/layui.js"></script>
<script src="~/Content/js/vendors/jsPanel/jquery.jspanel.js"></script>
<script type="text/javascript">
    $(function () {
        $("#PROJECTID").val(parent.ID);
        layui.use(["layer", "laydate"], function () {
            var laydate = layui.laydate;
            laydate.render({
                trigger: 'click', //采用click弹出
                elem: '#EVENTTIMETYPE',   //项目开始日期
                type: 'datetime'

            });
        })
        $("#slimScroll").slimScroll({
            height: "400px",
        });
        LoadTAG();
        $("#btnSave").click(function () {
            if ($("#mainForm").valid()) {
                $("#TAGID").val($("#sel_TAG").val());
                $('#mainForm').ajaxSubmit(function (data) {
                    if (data == "true") {
                        parent.LoadTag();
                        parent.AlertInfo("添加成功！", "success");
                    } else if (data == "false") {
                        parent.AlertInfo("添加失败！", "error");
                    }
                    else {
                        parent.AlertInfo(data, "error");
                    }
                });
            }
        });
    });
    /*查看帮助*/
    $("#btnUser").click(function () {
        //function DEPTView() {
        var parturl = path + "Department/UserHelp";
        UserInfo = $.jsPanel({
            resizable: "disabled",
            id: 'View',
            headerTitle: "用户信息帮助",
            content: '<iframe src="' + parturl + '" width="100%" height="100%" frameborder="0" />',
            position: 'center',
            contentSize: { width: 850, height: 350 },
            contentOverflow: 'hidden',
            theme: '#31435e',
            headerControls: {
                controls: 'closeonly'
            }
        });
    });
    //下拉框
    function LoadTAG() {
        //$("#sel_LoadDEPARTMENT").html(html);
        //$("#sel_LoadDEPARTMENT").select2();
        $.ajax({
            url: path + "Event/GetAllTagSel",
            type: 'post',
            data: { "PROJECTID": parent.ID },
            dataType: "json",
            success: function (res) {
                if (res != null) {
                    var sel = document.getElementById("sel_TAG");//获取下拉选对象
                    for (var i = 0, l = res.length; i < l; i++) {
                        var name = res[i].name;
                        var value = res[i].value;
                        var option = new Option(name, value,true, true); 
                        sel.options.add(option);
                                            
                    }
                    $("#sel_TAG").select2({
                        tags: true
                    });
                    $("#sel_TAG").val('@Model.TAG.Id').trigger('change');
                    return;
                }
            }
        })
    }
</script>
<div class="powerwidget" data-widget-editbutton="false" style="margin-bottom:0px">
    <div class="inner-spacer">
        <div id="slimScroll">
            @using (Html.BeginForm("Update", "Event", FormMethod.Post, new { @class = "form-horizontal", @id = "mainForm", @style = "margin-bottom:0px" }))
            {
            <fieldset>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="textinput">事件名称</label>
                    <div class="col-md-10">
                        @Html.HiddenFor(item => item.Id)
                        @Html.TextBoxFor(item => item.EVENTNAME, new { @class = "form-control required" })
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="textinput">事件时间</label>
                    <div class="col-md-10">
                        @Html.TextBoxFor(item => item.EVENTTIMETYPE, new { @class = "form-control required", @id = "EVENTTIMETYPE" })
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="textinput">参与人</label>
                    <div class="col-md-8">
                        @Html.TextBoxFor(item => item.MANAGER.USERNAME, new { @class = "form-control required", @id = "User", @readonly = "readonly" })
                    </div>
                    <div class="col-md-2">
                        <button id="btnUser" type="button" class="btn btn-success">选择</button>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="textinput">标签</label>
                    <div class="col-md-10">
                        <select id="sel_TAG" name="sel_TAG" class="form-control" required></select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-2 control-label" for="textinput">描述</label>
                    <div class="col-md-10">
                        @Html.TextBoxFor(item => item.DEPICT, new { @class = "form-control" })
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-12" style="text-align:center">
                        <button id="btnSave" type="button" class="btn btn-info">保存</button>
                    </div>
                </div>
                <div class="form-group" style="display:none">
                    <div class="col-md-8">
                        @Html.TextBoxFor(item => item.TAG.Id, new { @class = "form-control", @id = "TAGID", @readonly = "readonly" })
                        @*@Html.TextBoxFor(item => item.TAG.PROJECT.Id, new { @class = "form-control", @id = "PROJECT", @readonly = "readonly" })*@
                        @Html.TextBoxFor(item => item.MANAGER.Id, new { @class = "form-control", @id = "UserID", @readonly = "readonly" })
                        @Html.TextBoxFor(item => item.PROJECTID.Id, new { @class = "form-control", @id = "PROJECTID", @readonly = "readonly" })
                    </div>
                </div>
            </fieldset>
            }
        </div>
    </div>
</div>


